﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SC2Ranks
{
    [DataContract]
    public  class PlayerSearchInfo
    { 
        public static PlayerSearchInfo CreateByCharacterCode(Region region, string name, int characterCode) 
        {
            return new PlayerSearchInfo { Name = name, Region = region, CharacterCode = characterCode };
        }

        public static PlayerSearchInfo CreateByBNetID(Region region, string name, int bnetID)
        {
            return new PlayerSearchInfo { Name = name, Region = region, BattleNetID = bnetID };
        }

        [DataMember(Name = "region")]
        protected string RegionRaw { get; set; }

        public Region Region 
        {
            get { return Helper.ParseRegion(RegionRaw); }
            set { RegionRaw = Helper.ConvertRegion(value); } 
        }

        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "code")]
        public int? CharacterCode { get; set; }

        [DataMember(Name = "bnet_id", IsRequired = false)]
        public int? BattleNetID { get; set; }
    }
}
